<?php

// +----------------------------------------------------------------------
// | MyCentOS
// +----------------------------------------------------------------------
// | Copyright (c) 2014 http://www.mycentos.com, All rights reserved.
// +----------------------------------------------------------------------
// | Author: 琥珀 <317559272@qqq.com><http://www.mycentos.com>
// +----------------------------------------------------------------------
// | @date  : 2015-03-05 14:13:54
// +----------------------------------------------------------------------
// | @l Modified by:  琥珀
// +----------------------------------------------------------------------
// | @l Modified time: 2015-03-19 15:52:08
// +-----------------------------------------------------------------------


/**
 * 首页控制器
 * @authors 琥珀 (317559272@qq.com)
 */
namespace Admin\Controller;
use Think\Controller;
Class IndexController extends AdminController
{
    public function index() {
        $user = session('user_auth');
        if ($user['deafult_hospital_id']) {
            $map['id'] = $user['deafult_hospital_id'];
            $hospital = M('Hospital')->where($map)->find();
        }

        /************************************************/

        /*导医部门首页直接显示列表*/
        switch ($user['depart_id']) {
            case '7':
                $this->assign('url', '/Order/index');
                break;

            default:
                $this->assign('url', '/Index/data');
                break;
        }

        /***********************************************/
        $this->assign('user', $user);
        $this->assign('hospital', $hospital);
        $this->display();
    }
    public function myData() {
        $user = session('user_auth');
        p($user);
        $this->display();
    }
    public function data() {
        $user = session('user_auth');

        //切换医院
        $do = I('do');
        $hospital_select = I('hospital_select');
        if ($do == "change") {
            session('user_auth.deafult_hospital_id', $hospital_select);
        }
        if ($user['deafult_hospital_id']) {
            $map['id'] = $user['deafult_hospital_id'];
            $hospital = M('Hospital')->where($map)->find();
        }
        if ($user['uid'] === '1') {
            $hospital_list = M('Hospital')->where()->select();
        }
        if ($user['hospital_id']) {
            $data = explode(",", $user['hospital_id']);
            if (is_array($data)) {
                $map['id'] = array("in", $data);
                $hospital_list = M('Hospital')->where($map)->select();
            }
        }

        /*******************************/

        /*判断是否显示多选医院选项*/
        if (($user['uid'] !== '1') && (!is_array($user['hospital_id']))) {
            $this->assign('single', true);
        }

        /******************************/
        $this->assign('user', $user);
        $this->assign('hospital', $hospital);
        $this->assign('hospital_list', $hospital_list);

        //获取数据
        $order = M('Order');

        // 时间界限定义:
        //今天开始
        $time_t_begin = mktime(0, 0, 0);

        //今天结束
        $time_t_end = $time_t_begin + 24 * 3600;

        //昨天开始
        $time_y_begin = $time_t_begin - 24 * 3600;

        //本月开始
        $time_this_m_begin = mktime(0, 0, 0, date("month"), 1);

        //本月结束
        $time_this_m_end = strtotime("+1 month", $time_this_m_begin);

        //上个月开始
        $time_l_m_begin = strtotime("-1 month", $time_this_m_begin);

        //上个月同天开始
        $time_l_day_begin = strtotime(date('Y-m-d', strtotime('last month')));

        //上个月同天结束
        $time_l_day_end = $time_l_day_begin + 24 * 3600;

        //同期时间结束
        $time_l_m_end = strtotime("-1 month", time());

        //定义链接
        $time_t = "t";
        $time_y = "y";
        $time_l_m_t = "l_m_t";
        $time_this_m = "thism";
        $time_l_m = "lm";
        $status_come = "1";
        $status_not = "0";
        $part_web = "25,26";
        $part_tel = "3";
        $part_zg = "4";

        //总体查询条件
        $w_t['order_date'] = array(array('egt', $time_t_begin), array('lt', $time_t_end));
        $w_y['order_date'] = array(array('egt', $time_y_begin), array('lt', $time_t_begin));
        $w_l_m_t['order_date'] = array(array('egt', $time_l_m_begin), array('lt', $time_l_m_end));
        $w_this_m['order_date'] = array(array('egt', $time_this_m_begin), array('lt', $time_this_m_end));
        $w_l_m['order_date'] = array(array('egt', $time_l_m_begin), array('lt', $time_this_m_begin));
        $w_status_come['status'] = "1";
        $w_status_not['status'] = "0";
        $w_z['memo'] = array('like', '%z%');
        $w_web['part_id'] = array('in', array('25', '26'));
        $w_tel['part_id'] = '3';
        $w_zg['part_id'] = '4';
        /**********************************************************
         * 整院预约统计                                           *
         * @authors 琥珀 (317559272@qq.com)                       *
         * @date    2015-02-03                                    *
         **********************************************************/
        $t_all = $order->where($w_t)->count();
        $t_all_come = $order->where($w_t)->where($w_status_come)->count();
        $t_all_not = $t_all - $t_all_come;
        $t_all_z = $order->where($w_t)->where($w_status_not)->where($w_z)->count();

        //总体查询数据昨日
        $y_all = $order->where($w_y)->count();
        $y_all_come = $order->where($w_y)->where($w_status_come)->count();
        $y_all_not = $y_all - $y_all_come;
        $y_all_z = $order->where($w_y)->where($w_status_not)->where($w_z)->count();

        //同期当月查询数据
        $l_m_t_all = $order->where($w_l_m_t)->count();
        $l_m_t_all_come = $order->where($w_l_m_t)->where($w_status_come)->count();
        $l_m_t_all_not = $l_m_t_all - $l_m_t_all_come;
        $l_m_t_all_z = $order->where($w_l_m_t)->where($w_status_not)->where($w_z)->count();

        //本月查询数据
        $this_m_all = $order->where($w_this_m)->count();
        $this_m_all_come = $order->where($w_this_m)->where($w_status_come)->count();
        $this_m_all_not = $l_m_t_all - $this_m_all_come;
        $this_m_all_z = $order->where($w_this_m)->where($w_status_not)->where($w_z)->count();

        //上月查询数据
        $l_m_all = $order->where($w_l_m)->count();
        $l_m_all_come = $order->where($w_l_m)->where($w_status_come)->count();
        $l_m_all_not = $l_m_all - $l_m_all_come;
        $l_m_all_z = $order->where($w_l_m)->where($w_status_not)->where($w_z)->count();

        //整体预约统计链接
        $data = 'data-toggle="navtab" data-id="Order" data-title="预约列表"';
        $t_all = '<a href="/order/index/time/' . $time_t . '"' . $data . '>' . $t_all . '</a>';
        $t_all_come = '<a href="/order/index/time/' . $time_t . '/status/' . $status_come . '" ' . $data . '>' . $t_all_come . '</a>';
        $t_all_not = '<a href="/order/index/time/' . $time_t . '/status/' . $status_not . '" ' . $data . '>' . $t_all_not . '</a>';
        $t_all_z = '<a href="/order/index/time/' . $time_t . '/keyword/' . $status_come . '" ' . $data . '>' . $t_all_z . '</a>';
        $y_all = '<a href="/order/index/time/' . $time_y . '" ' . $data . '>' . $y_all . '</a>';
        $y_all_come = '<a href="/order/index/time/' . $time_y . '/status/' . $status_come . '" ' . $data . '>' . $y_all_come . '</a>';
        $y_all_not = '<a href="/order/index/time/' . $time_y . '/status/' . $status_not . '" ' . $data . '>' . $y_all_not . '</a>';
        $y_all_z = '<a href="/order/index/time/' . $time_y . '/keyword/' . $status_come . '" ' . $data . '>' . $y_all_z . '</a>';
        $l_m_t_all = '<a href="/order/index/time/' . $time_l_m_t . '" ' . $data . '>' . $l_m_t_all . '</a>';
        $l_m_t_all_come = '<a href="/order/index/time/' . $time_l_m_t . '/status/' . $status_come . '" ' . $data . '>' . $l_m_t_all_come . '</a>';
        $l_m_t_all_not = '<a href="/order/index/time/' . $time_l_m_t . '/status/' . $status_not . '" ' . $data . '>' . $l_m_t_all_not . '</a>';
        $l_m_t_all_z = '<a href="/order/index/time/' . $time_l_m_t . '/keyword/' . $status_come . '" ' . $data . '>' . $l_m_t_all_z . '</a>';
        $this_m_all = '<a href="/order/index/time/' . $time_this_m . '" ' . $data . '>' . $this_m_all . '</a>';
        $this_m_all_come = '<a href="/order/index/time/' . $time_this_m . '/status/' . $status_come . '" ' . $data . '>' . $this_m_all_come . '</a>';
        $this_m_all_not = '<a href="/order/index/time/' . $time_this_m . '/status/' . $status_not . '" ' . $data . '>' . $this_m_all_not . '</a>';
        $this_m_all_z = '<a href="/order/index/time/' . $time_this_m . '/keyword/' . $status_come . '" ' . $data . '>' . $this_m_all_z . '</a>';
        $l_m_all = '<a href="/order/index/time/' . $time_l_m . '" ' . $data . '>' . $l_m_all . '</a>';
        $l_m_all_come = '<a href="/order/index/time/' . $time_l_m . '/status/' . $status_come . '" ' . $data . '>' . $l_m_all_come . '</a>';
        $l_m_all_not = '<a href="/order/index/time/' . $time_l_m . '/status/' . $status_not . '" ' . $data . '>' . $l_m_all_not . '</a>';
        $l_m_all_z = '<a href="/order/index/time/' . $time_l_m . '/keyword/' . $status_come . '" ' . $data . '>' . $l_m_all_z . '</a>';

        /**********************************************************
         * 网络预约统计                                           *
         * @authors 琥珀 (317559272@qq.com)                       *
         * @date    2015-02-03                                    *
         **********************************************************/
        $t_web = $order->where($w_t)->where($w_web)->count();
        $t_web_come = $order->where($w_t)->where($w_status_come)->where($w_web)->count();
        $t_web_not = $t_web - $t_web_come;
        $t_web_z = $order->where($w_t)->where($w_status_not)->where($w_z)->where($w_web)->count();

        //总体查询数据昨日
        $y_web = $order->where($w_y)->where($w_web)->count();
        $y_web_come = $order->where($w_y)->where($w_status_come)->where($w_web)->count();
        $y_web_not = $y_web - $y_web_come;
        $y_web_z = $order->where($w_y)->where($w_status_not)->where($w_z)->where($w_web)->count();

        //同期当月查询数据
        $l_m_t_web = $order->where($w_l_m_t)->where($w_web)->count();
        $l_m_t_web_come = $order->where($w_l_m_t)->where($w_status_come)->where($w_web)->count();
        $l_m_t_web_not = $l_m_t_web - $l_m_t_web_come;
        $l_m_t_web_z = $order->where($w_l_m_t)->where($w_status_not)->where($w_z)->where($w_web)->count();

        //本月查询数据
        $this_m_web = $order->where($w_this_m)->where($w_web)->count();
        $this_m_web_come = $order->where($w_this_m)->where($w_status_come)->where($w_web)->count();
        $this_m_web_not = $l_m_t_web - $this_m_web_come;
        $this_m_web_z = $order->where($w_this_m)->where($w_status_not)->where($w_z)->where($w_web)->count();

        //上月查询数据
        $l_m_web = $order->where($w_l_m)->where($w_web)->count();
        $l_m_web_come = $order->where($w_l_m)->where($w_status_come)->where($w_web)->count();
        $l_m_web_not = $l_m_web - $l_m_web_come;
        $l_m_web_z = $order->where($w_l_m)->where($w_status_not)->where($w_z)->where($w_web)->count();

        //链接
        $data = 'data-toggle="navtab" data-id="Order" data-title="预约列表"';
        $t_web = '<a href="/order/index/time/' . $time_t . '/part/' . $part_web . '"' . $data . '>' . $t_web . '</a>';
        $t_web_come = '<a href="/order/index/time/' . $time_t . '/part/' . $part_web . '/status/' . $status_come . '" ' . $data . '>' . $t_web_come . '</a>';
        $t_web_not = '<a href="/order/index/time/' . $time_t . '/part/' . $part_web . '/status/' . $status_not . '" ' . $data . '>' . $t_web_not . '</a>';
        $t_web_z = '<a href="/order/index/time/' . $time_t . '/part/' . $part_web . '/keyword/' . $status_come . '" ' . $data . '>' . $t_web_z . '</a>';
        $y_web = '<a href="/order/index/time/' . $time_y . '/part/' . $part_web . '" ' . $data . '>' . $y_web . '</a>';
        $y_web_come = '<a href="/order/index/time/' . $time_y . '/part/' . $part_web . '/status/' . $status_come . '" ' . $data . '>' . $y_web_come . '</a>';
        $y_web_not = '<a href="/order/index/time/' . $time_y . '/part/' . $part_web . '/status/' . $status_not . '" ' . $data . '>' . $y_web_not . '</a>';
        $y_web_z = '<a href="/order/index/time/' . $time_y . '/part/' . $part_web . '/keyword/' . $status_come . '" ' . $data . '>' . $y_web_z . '</a>';
        $l_m_t_web = '<a href="/order/index/time/' . $time_l_m_t . '/part/' . $part_web . '" ' . $data . '>' . $l_m_t_web . '</a>';
        $l_m_t_web_come = '<a href="/order/index/time/' . $time_l_m_t . '/part/' . $part_web . '/status/' . $status_come . '" ' . $data . '>' . $l_m_t_web_come . '</a>';
        $l_m_t_web_not = '<a href="/order/index/time/' . $time_l_m_t . '/part/' . $part_web . '/status/' . $status_not . '" ' . $data . '>' . $l_m_t_web_not . '</a>';
        $l_m_t_web_z = '<a href="/order/index/time/' . $time_l_m_t . '/part/' . $part_web . '/keyword/' . $status_come . '" ' . $data . '>' . $l_m_t_web_z . '</a>';
        $this_m_web = '<a href="/order/index/time/' . $time_this_m . '/part/' . $part_web . '" ' . $data . '>' . $this_m_web . '</a>';
        $this_m_web_come = '<a href="/order/index/time/' . $time_this_m . '/part/' . $part_web . '/status/' . $status_come . '" ' . $data . '>' . $this_m_web_come . '</a>';
        $this_m_web_not = '<a href="/order/index/time/' . $time_this_m . '/part/' . $part_web . '/status/' . $status_not . '" ' . $data . '>' . $this_m_web_not . '</a>';
        $this_m_web_z = '<a href="/order/index/time/' . $time_this_m . '/part/' . $part_web . '/keyword/' . $status_come . '" ' . $data . '>' . $this_m_web_z . '</a>';
        $l_m_web = '<a href="/order/index/time/' . $time_l_m . '/part/' . $part_web . '" ' . $data . '>' . $l_m_web . '</a>';
        $l_m_web_come = '<a href="/order/index/time/' . $time_l_m . '/part/' . $part_web . '/status/' . $status_come . '" ' . $data . '>' . $l_m_web_come . '</a>';
        $l_m_web_not = '<a href="/order/index/time/' . $time_l_m . '/part/' . $part_web . '/status/' . $status_not . '" ' . $data . '>' . $l_m_web_not . '</a>';
        $l_m_web_z = '<a href="/order/index/time/' . $time_l_m . '/part/' . $part_web . '/keyword/' . $status_come . '" ' . $data . '>' . $l_m_web_z . '</a>';

        /**********************************************************
         * 电话预约统计                                           *
         * @authors 琥珀 (317559272@qq.com)                       *
         * @date    2015-02-03                                    *
         **********************************************************/
        $t_tel = $order->where($w_t)->where($w_tel)->count();
        $t_tel_come = $order->where($w_t)->where($w_status_come)->where($w_tel)->count();
        $t_tel_not = $t_tel - $t_tel_come;
        $t_tel_z = $order->where($w_t)->where($w_status_not)->where($w_z)->where($w_tel)->count();

        //总体查询数据昨日
        $y_tel = $order->where($w_y)->where($w_tel)->count();
        $y_tel_come = $order->where($w_y)->where($w_status_come)->where($w_tel)->count();
        $y_tel_not = $y_tel - $y_tel_come;
        $y_tel_z = $order->where($w_y)->where($w_status_not)->where($w_z)->where($w_tel)->count();

        //同期当月查询数据
        $l_m_t_tel = $order->where($w_l_m_t)->where($w_tel)->count();
        $l_m_t_tel_come = $order->where($w_l_m_t)->where($w_status_come)->where($w_tel)->count();
        $l_m_t_tel_not = $l_m_t_tel - $l_m_t_tel_come;
        $l_m_t_tel_z = $order->where($w_l_m_t)->where($w_status_not)->where($w_z)->where($w_tel)->count();

        //本月查询数据
        $this_m_tel = $order->where($w_this_m)->where($w_tel)->count();
        $this_m_tel_come = $order->where($w_this_m)->where($w_status_come)->where($w_tel)->count();
        $this_m_tel_not = $l_m_t_tel - $this_m_tel_come;
        $this_m_tel_z = $order->where($w_this_m)->where($w_status_not)->where($w_z)->where($w_tel)->count();

        //上月查询数据
        $l_m_tel = $order->where($w_l_m)->where($w_tel)->count();
        $l_m_tel_come = $order->where($w_l_m)->where($w_status_come)->where($w_tel)->count();
        $l_m_tel_not = $l_m_tel - $l_m_tel_come;
        $l_m_tel_z = $order->where($w_l_m)->where($w_status_not)->where($w_z)->where($w_tel)->count();

        //链接
        $data = 'data-toggle="navtab" data-id="Order" data-title="预约列表"';
        $t_tel = '<a href="/order/index/time/' . $time_t . '/part/' . $part_tel . '"' . $data . '>' . $t_tel . '</a>';
        $t_tel_come = '<a href="/order/index/time/' . $time_t . '/part/' . $part_tel . '/status/' . $status_come . '" ' . $data . '>' . $t_tel_come . '</a>';
        $t_tel_not = '<a href="/order/index/time/' . $time_t . '/part/' . $part_tel . '/status/' . $status_not . '" ' . $data . '>' . $t_tel_not . '</a>';
        $t_tel_z = '<a href="/order/index/time/' . $time_t . '/part/' . $part_tel . '/keyword/' . $status_come . '" ' . $data . '>' . $t_tel_z . '</a>';
        $y_tel = '<a href="/order/index/time/' . $time_y . '/part/' . $part_tel . '" ' . $data . '>' . $y_tel . '</a>';
        $y_tel_come = '<a href="/order/index/time/' . $time_y . '/part/' . $part_tel . '/status/' . $status_come . '" ' . $data . '>' . $y_tel_come . '</a>';
        $y_tel_not = '<a href="/order/index/time/' . $time_y . '/part/' . $part_tel . '/status/' . $status_not . '" ' . $data . '>' . $y_tel_not . '</a>';
        $y_tel_z = '<a href="/order/index/time/' . $time_y . '/part/' . $part_tel . '/keyword/' . $status_come . '" ' . $data . '>' . $y_tel_z . '</a>';
        $l_m_t_tel = '<a href="/order/index/time/' . $time_l_m_t . '/part/' . $part_tel . '" ' . $data . '>' . $l_m_t_tel . '</a>';
        $l_m_t_tel_come = '<a href="/order/index/time/' . $time_l_m_t . '/part/' . $part_tel . '/status/' . $status_come . '" ' . $data . '>' . $l_m_t_tel_come . '</a>';
        $l_m_t_tel_not = '<a href="/order/index/time/' . $time_l_m_t . '/part/' . $part_tel . '/status/' . $status_not . '" ' . $data . '>' . $l_m_t_tel_not . '</a>';
        $l_m_t_tel_z = '<a href="/order/index/time/' . $time_l_m_t . '/part/' . $part_tel . '/keyword/' . $status_come . '" ' . $data . '>' . $l_m_t_tel_z . '</a>';
        $this_m_tel = '<a href="/order/index/time/' . $time_this_m . '/part/' . $part_tel . '" ' . $data . '>' . $this_m_tel . '</a>';
        $this_m_tel_come = '<a href="/order/index/time/' . $time_this_m . '/part/' . $part_tel . '/status/' . $status_come . '" ' . $data . '>' . $this_m_tel_come . '</a>';
        $this_m_tel_not = '<a href="/order/index/time/' . $time_this_m . '/part/' . $part_tel . '/status/' . $status_not . '" ' . $data . '>' . $this_m_tel_not . '</a>';
        $this_m_tel_z = '<a href="/order/index/time/' . $time_this_m . '/part/' . $part_tel . '/keyword/' . $status_come . '" ' . $data . '>' . $this_m_tel_z . '</a>';
        $l_m_tel = '<a href="/order/index/time/' . $time_l_m . '/part/' . $part_tel . '" ' . $data . '>' . $l_m_tel . '</a>';
        $l_m_tel_come = '<a href="/order/index/time/' . $time_l_m . '/part/' . $part_tel . '/status/' . $status_come . '" ' . $data . '>' . $l_m_tel_come . '</a>';
        $l_m_tel_not = '<a href="/order/index/time/' . $time_l_m . '/part/' . $part_tel . '/status/' . $status_not . '" ' . $data . '>' . $l_m_tel_not . '</a>';
        $l_m_tel_z = '<a href="/order/index/time/' . $time_l_m . '/part/' . $part_tel . '/keyword/' . $status_come . '" ' . $data . '>' . $l_m_tel_z . '</a>';

        //获取医院科室
        $dps = $user['data_id'];
        if (!empty($dps)) {
            $dps = explode(",", $dps);
            $dps['id'] = array('in', $dps);
            $department = M('Department')->where($dps)->field('id,name')->select();
            $dp = array();
            foreach ($department as $key => $value) {
                $w_dp['dp'] = $value['id'];
                $t_dp = $order->where($w_t)->where($w_web)->where($w_dp)->count();
                $t_dp_come = $order->where($w_t)->where($w_status_come)->where($w_web)->where($w_dp)->count();
                $t_dp_not = $t_dp - $t_dp_come;
                $t_dp_z = $order->where($w_t)->where($w_status_not)->where($w_z)->where($w_web)->where($w_dp)->count();

                //总体查询数据昨日
                $y_dp = $order->where($w_y)->where($w_web)->where($w_dp)->count();
                $y_dp_come = $order->where($w_y)->where($w_status_come)->where($w_web)->where($w_dp)->count();
                $y_dp_not = $y_dp - $y_dp_come;
                $y_dp_z = $order->where($w_y)->where($w_status_not)->where($w_z)->where($w_web)->where($w_dp)->count();

                //同期当月查询数据
                $l_m_t_dp = $order->where($w_l_m_t)->where($w_web)->where($w_dp)->count();
                $l_m_t_dp_come = $order->where($w_l_m_t)->where($w_status_come)->where($w_web)->where($w_dp)->count();
                $l_m_t_dp_not = $l_m_t_dp - $l_m_t_dp_come;
                $l_m_t_dp_z = $order->where($w_l_m_t)->where($w_status_not)->where($w_z)->where($w_web)->where($w_dp)->count();

                //本月查询数据
                $this_m_dp = $order->where($w_this_m)->where($w_web)->where($w_dp)->count();
                $this_m_dp_come = $order->where($w_this_m)->where($w_status_come)->where($w_web)->where($w_dp)->count();
                $this_m_dp_not = $l_m_t_dp - $this_m_dp_come;
                $this_m_dp_z = $order->where($w_this_m)->where($w_status_not)->where($w_z)->where($w_web)->where($w_dp)->count();

                //上月查询数据
                $l_m_dp = $order->where($w_l_m)->where($w_web)->where($w_dp)->count();
                $l_m_dp_come = $order->where($w_l_m)->where($w_status_come)->where($w_web)->where($w_dp)->count();
                $l_m_dp_not = $l_m_dp - $l_m_dp_come;
                $l_m_dp_z = $order->where($w_l_m)->where($w_status_not)->where($w_z)->where($w_web)->where($w_dp)->count();

                //链接
                $dp[$key]['data'] = 'data-toggle="navtab" data-id="Order" data-title="预约列表"';
                $dp[$key]['dp'] = $value['name'];
                $dp[$key]['t_dp'] = '<a href="/order/index/time/' . $time_t . '/part/' . $part_web . '"' . $data . '>' . $t_dp . '</a>';
                $dp[$key]['t_dp_come'] = '<a href="/order/index/time/' . $time_t . '/part/' . $part_web . '/status/' . $status_come . '" ' . $data . '>' . $t_dp_come . '</a>';
                $dp[$key]['t_dp_not'] = '<a href="/order/index/time/' . $time_t . '/part/' . $part_web . '/status/' . $status_not . '" ' . $data . '>' . $t_dp_not . '</a>';
                $dp[$key]['t_dp_z'] = '<a href="/order/index/time/' . $time_t . '/part/' . $part_web . '/keyword/' . $status_come . '" ' . $data . '>' . $t_dp_z . '</a>';
                $dp[$key]['y_dp'] = '<a href="/order/index/time/' . $time_y . '/part/' . $part_web . '" ' . $data . '>' . $y_web . '</a>';
                $dp[$key]['y_dp_come'] = '<a href="/order/index/time/' . $time_y . '/part/' . $part_web . '/status/' . $status_come . '" ' . $data . '>' . $y_dp_come . '</a>';
                $dp[$key]['y_dp_not'] = '<a href="/order/index/time/' . $time_y . '/part/' . $part_web . '/status/' . $status_not . '" ' . $data . '>' . $y_dp_not . '</a>';
                $dp[$key]['y_dp_z'] = '<a href="/order/index/time/' . $time_y . '/part/' . $part_web . '/keyword/' . $status_come . '" ' . $data . '>' . $y_dp_z . '</a>';
                $dp[$key]['l_m_t_dp'] = '<a href="/order/index/time/' . $time_l_m_t . '/part/' . $part_web . '" ' . $data . '>' . $l_m_t_dp . '</a>';
                $dp[$key]['l_m_t_dp_come'] = '<a href="/order/index/time/' . $time_l_m_t . '/part/' . $part_web . '/status/' . $status_come . '" ' . $data . '>' . $l_m_t_dp_come . '</a>';
                $dp[$key]['l_m_t_dp_not'] = '<a href="/order/index/time/' . $time_l_m_t . '/part/' . $part_web . '/status/' . $status_not . '" ' . $data . '>' . $l_m_t_dp_not . '</a>';
                $dp[$key]['l_m_t_dp_z'] = '<a href="/order/index/time/' . $time_l_m_t . '/part/' . $part_web . '/keyword/' . $status_come . '" ' . $data . '>' . $l_m_t_dp_z . '</a>';
                $dp[$key]['this_m_dp'] = '<a href="/order/index/time/' . $time_this_m . '/part/' . $part_web . '" ' . $data . '>' . $this_m_web . '</a>';
                $dp[$key]['this_m_dp_come'] = '<a href="/order/index/time/' . $time_this_m . '/part/' . $part_web . '/status/' . $status_come . '" ' . $data . '>' . $this_m_dp_come . '</a>';
                $dp[$key]['this_m_dp_not'] = '<a href="/order/index/time/' . $time_this_m . '/part/' . $part_web . '/status/' . $status_not . '" ' . $data . '>' . $this_m_dp_not . '</a>';
                $dp[$key]['this_m_dp_z'] = '<a href="/order/index/time/' . $time_this_m . '/part/' . $part_web . '/keyword/' . $status_come . '" ' . $data . '>' . $this_m_dp_z . '</a>';
                $dp[$key]['l_m_dp'] = '<a href="/order/index/time/' . $time_l_m . '/part/' . $part_web . '" ' . $data . '>' . $l_m_web . '</a>';
                $dp[$key]['l_m_dp_come'] = '<a href="/order/index/time/' . $time_l_m . '/part/' . $part_web . '/status/' . $status_come . '" ' . $data . '>' . $l_m_dp_come . '</a>';
                $dp[$key]['l_m_dp_not'] = '<a href="/order/index/time/' . $time_l_m . '/part/' . $part_web . '/status/' . $status_not . '" ' . $data . '>' . $l_m_dp_not . '</a>';
                $dp[$key]['l_m_dp_z'] = '<a href="/order/index/time/' . $time_l_m . '/part/' . $part_web . '/keyword/' . $status_come . '" ' . $data . '>' . $l_m_dp_z . '</a>';
            }
        }
        $this->assign('dp', $dp);

        /**********************************************************
         * 自挂预约统计                                           *
         * @authors 琥珀 (317559272@qq.com)                       *
         * @date    2015-02-03                                    *
         **********************************************************/
        $t_zg = $order->where($w_t)->where($w_zg)->count();
        $t_zg_come = $order->where($w_t)->where($w_status_come)->where($w_zg)->count();
        $t_zg_not = $t_zg - $t_zg_come;
        $t_zg_z = $order->where($w_t)->where($w_status_not)->where($w_z)->where($w_zg)->count();

        //总体查询数据昨日
        $y_zg = $order->where($w_y)->where($w_zg)->count();
        $y_zg_come = $order->where($w_y)->where($w_status_come)->where($w_zg)->count();
        $y_zg_not = $y_zg - $y_zg_come;
        $y_zg_z = $order->where($w_y)->where($w_status_not)->where($w_z)->where($w_zg)->count();

        //同期当月查询数据
        $l_m_t_zg = $order->where($w_l_m_t)->where($w_zg)->count();
        $l_m_t_zg_come = $order->where($w_l_m_t)->where($w_status_come)->where($w_zg)->count();
        $l_m_t_zg_not = $l_m_t_zg - $l_m_t_zg_come;
        $l_m_t_zg_z = $order->where($w_l_m_t)->where($w_status_not)->where($w_z)->where($w_zg)->count();

        //本月查询数据
        $this_m_zg = $order->where($w_this_m)->where($w_zg)->count();
        $this_m_zg_come = $order->where($w_this_m)->where($w_status_come)->where($w_zg)->count();
        $this_m_zg_not = $l_m_t_zg - $this_m_zg_come;
        $this_m_zg_z = $order->where($w_this_m)->where($w_status_not)->where($w_z)->where($w_zg)->count();

        //上月查询数据
        $l_m_zg = $order->where($w_l_m)->where($w_zg)->count();
        $l_m_zg_come = $order->where($w_l_m)->where($w_status_come)->where($w_zg)->count();
        $l_m_zg_not = $l_m_zg - $l_m_zg_come;
        $l_m_zg_z = $order->where($w_l_m)->where($w_status_not)->where($w_z)->where($w_zg)->count();

        //链接
        $data = 'data-toggle="navtab" data-id="Order" data-title="预约列表"';
        $t_zg = '<a href="/order/index/time/' . $time_t . '/part/' . $part_zg . '"' . $data . '>' . $t_zg . '</a>';
        $t_zg_come = '<a href="/order/index/time/' . $time_t . '/part/' . $part_zg . '/status/' . $status_come . '" ' . $data . '>' . $t_zg_come . '</a>';
        $t_zg_not = '<a href="/order/index/time/' . $time_t . '/part/' . $part_zg . '/status/' . $status_not . '" ' . $data . '>' . $t_zg_not . '</a>';
        $t_zg_z = '<a href="/order/index/time/' . $time_t . '/part/' . $part_zg . '/keyword/' . $status_come . '" ' . $data . '>' . $t_zg_z . '</a>';
        $y_zg = '<a href="/order/index/time/' . $time_y . '/part/' . $part_zg . '" ' . $data . '>' . $y_zg . '</a>';
        $y_zg_come = '<a href="/order/index/time/' . $time_y . '/part/' . $part_zg . '/status/' . $status_come . '" ' . $data . '>' . $y_zg_come . '</a>';
        $y_zg_not = '<a href="/order/index/time/' . $time_y . '/part/' . $part_zg . '/status/' . $status_not . '" ' . $data . '>' . $y_zg_not . '</a>';
        $y_zg_z = '<a href="/order/index/time/' . $time_y . '/part/' . $part_zg . '/keyword/' . $status_come . '" ' . $data . '>' . $y_zg_z . '</a>';
        $l_m_t_zg = '<a href="/order/index/time/' . $time_l_m_t . '/part/' . $part_zg . '" ' . $data . '>' . $l_m_t_zg . '</a>';
        $l_m_t_zg_come = '<a href="/order/index/time/' . $time_l_m_t . '/part/' . $part_zg . '/status/' . $status_come . '" ' . $data . '>' . $l_m_t_zg_come . '</a>';
        $l_m_t_zg_not = '<a href="/order/index/time/' . $time_l_m_t . '/part/' . $part_zg . '/status/' . $status_not . '" ' . $data . '>' . $l_m_t_zg_not . '</a>';
        $l_m_t_zg_z = '<a href="/order/index/time/' . $time_l_m_t . '/part/' . $part_zg . '/keyword/' . $status_come . '" ' . $data . '>' . $l_m_t_zg_z . '</a>';
        $this_m_zg = '<a href="/order/index/time/' . $time_this_m . '/part/' . $part_zg . '" ' . $data . '>' . $this_m_zg . '</a>';
        $this_m_zg_come = '<a href="/order/index/time/' . $time_this_m . '/part/' . $part_zg . '/status/' . $status_come . '" ' . $data . '>' . $this_m_zg_come . '</a>';
        $this_m_zg_not = '<a href="/order/index/time/' . $time_this_m . '/part/' . $part_zg . '/status/' . $status_not . '" ' . $data . '>' . $this_m_zg_not . '</a>';
        $this_m_zg_z = '<a href="/order/index/time/' . $time_this_m . '/part/' . $part_zg . '/keyword/' . $status_come . '" ' . $data . '>' . $this_m_zg_z . '</a>';
        $l_m_zg = '<a href="/order/index/time/' . $time_l_m . '/part/' . $part_zg . '" ' . $data . '>' . $l_m_zg . '</a>';
        $l_m_zg_come = '<a href="/order/index/time/' . $time_l_m . '/part/' . $part_zg . '/status/' . $status_come . '" ' . $data . '>' . $l_m_zg_come . '</a>';
        $l_m_zg_not = '<a href="/order/index/time/' . $time_l_m . '/part/' . $part_zg . '/status/' . $status_not . '" ' . $data . '>' . $l_m_zg_not . '</a>';
        $l_m_zg_z = '<a href="/order/index/time/' . $time_l_m . '/part/' . $part_zg . '/keyword/' . $status_come . '" ' . $data . '>' . $l_m_zg_z . '</a>';

        /*************整院数据输出********************************/
        $this->assign('t_all', $t_all);
        $this->assign('t_all_come', $t_all_come);
        $this->assign('t_all_not', $t_all_not);
        $this->assign('t_all_z', $t_all_z);
        $this->assign('y_all', $y_all);
        $this->assign('y_all_come', $y_all_come);
        $this->assign('y_all_not', $y_all_not);
        $this->assign('y_all_z', $y_all_z);
        $this->assign('l_m_t_all', $l_m_t_all);
        $this->assign('l_m_t_all_come', $l_m_t_all_come);
        $this->assign('l_m_t_all_not', $l_m_t_all_not);
        $this->assign('l_m_t_all_z', $l_m_t_all_z);
        $this->assign('this_m_all', $this_m_all);
        $this->assign('this_m_all_come', $this_m_all_come);
        $this->assign('this_m_all_not', $this_m_all_not);
        $this->assign('this_m_all_z', $this_m_all_z);
        $this->assign('l_m_all', $l_m_all);
        $this->assign('l_m_all_come', $l_m_all_come);
        $this->assign('l_m_all_not', $l_m_all_not);
        $this->assign('l_m_all_z', $l_m_all_z);

        /**************网络数据输出************************************/
        $this->assign('t_web', $t_web);
        $this->assign('t_web_come', $t_web_come);
        $this->assign('t_web_not', $t_web_not);
        $this->assign('t_web_z', $t_web_z);
        $this->assign('y_web', $y_web);
        $this->assign('y_web_come', $y_web_come);
        $this->assign('y_web_not', $y_web_not);
        $this->assign('y_web_z', $y_web_z);
        $this->assign('l_m_t_web', $l_m_t_web);
        $this->assign('l_m_t_web_come', $l_m_t_web_come);
        $this->assign('l_m_t_web_not', $l_m_t_web_not);
        $this->assign('l_m_t_web_z', $l_m_t_web_z);
        $this->assign('this_m_web', $this_m_web);
        $this->assign('this_m_web_come', $this_m_web_come);
        $this->assign('this_m_web_not', $this_m_web_not);
        $this->assign('this_m_web_z', $this_m_web_z);
        $this->assign('l_m_web', $l_m_web);
        $this->assign('l_m_web_come', $l_m_web_come);
        $this->assign('l_m_web_not', $l_m_web_not);
        $this->assign('l_m_web_z', $l_m_web_z);

        /**************电话数据输出************************************/
        $this->assign('t_tel', $t_tel);
        $this->assign('t_tel_come', $t_tel_come);
        $this->assign('t_tel_not', $t_tel_not);
        $this->assign('t_tel_z', $t_tel_z);
        $this->assign('y_tel', $y_tel);
        $this->assign('y_tel_come', $y_tel_come);
        $this->assign('y_tel_not', $y_tel_not);
        $this->assign('y_tel_z', $y_tel_z);
        $this->assign('l_m_t_tel', $l_m_t_tel);
        $this->assign('l_m_t_tel_come', $l_m_t_tel_come);
        $this->assign('l_m_t_tel_not', $l_m_t_tel_not);
        $this->assign('l_m_t_tel_z', $l_m_t_tel_z);
        $this->assign('this_m_tel', $this_m_tel);
        $this->assign('this_m_tel_come', $this_m_tel_come);
        $this->assign('this_m_tel_not', $this_m_tel_not);
        $this->assign('this_m_tel_z', $this_m_tel_z);
        $this->assign('l_m_tel', $l_m_tel);
        $this->assign('l_m_tel_come', $l_m_tel_come);
        $this->assign('l_m_tel_not', $l_m_tel_not);
        $this->assign('l_m_tel_z', $l_m_tel_z);

        /**************自挂数据输出************************************/
        $this->assign('t_zg', $t_zg);
        $this->assign('t_zg_come', $t_zg_come);
        $this->assign('t_zg_not', $t_zg_not);
        $this->assign('t_zg_z', $t_zg_z);
        $this->assign('y_zg', $y_zg);
        $this->assign('y_zg_come', $y_zg_come);
        $this->assign('y_zg_not', $y_zg_not);
        $this->assign('y_zg_z', $y_zg_z);
        $this->assign('l_m_t_zg', $l_m_t_zg);
        $this->assign('l_m_t_zg_come', $l_m_t_zg_come);
        $this->assign('l_m_t_zg_not', $l_m_t_zg_not);
        $this->assign('l_m_t_zg_z', $l_m_t_zg_z);
        $this->assign('this_m_zg', $this_m_zg);
        $this->assign('this_m_zg_come', $this_m_zg_come);
        $this->assign('this_m_zg_not', $this_m_zg_not);
        $this->assign('this_m_zg_z', $this_m_zg_z);
        $this->assign('l_m_zg', $l_m_zg);
        $this->assign('l_m_zg_come', $l_m_zg_come);
        $this->assign('l_m_zg_not', $l_m_zg_not);
        $this->assign('l_m_zg_z', $l_m_zg_z);

        /*****************************************************************/

        //根据不同部门显示不同样的数据模块
        $this->assign('depart_id', $user['depart_id']);
        $this->display();
    }
}
?>